#include "mapper.h"
#include <map>
#include <algorithm>
#include <cassert>
using namespace std;

#define MP make_pair
#define PB push_back

void Mapper::build() {
  int landmark2class[] = {  0,   2,   4,   6,   1,   3,   5,   7,
                          100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 101, 103, 105, 107,
                          200, 202, 204, 206, 208, 210, 212, 214, 216, 218,
                          300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 309, 311, 313, 315,
                          401, 403, 405, 407, 409, 411, 413, 415, 417, 419, 400, 402, 404, 406,
                          501, 503, 505, 507, 509, 511, 513, 515, 517, 519,
                          601, 603, 605, 607, 609, 611, 613, 615, 617, 619, 608, 610, 612, 614,
                          708, 710, 712, 714, 709, 711, 713, 715};

  for (int class_id = 0; class_id < sizeof(landmark2class) / sizeof(int); ++class_id) {
    int now = landmark2class[class_id];
    int orientation = now / 100;
    int landmark_id = now % 100;
    L2C[MP(orientation, landmark_id)] = class_id;
    C2L[class_id] = landmark_id;
  }
}

Mapper::Mapper() {
  build();
}

int Mapper::getC(int orientation, int landmark_id) {
  pair<int, int> pii = MP(orientation, landmark_id);
  assert(L2C.find(pii) != L2C.end());
  return L2C[pii];
}

int Mapper::getL(int class_id) {
  assert(C2L.find(class_id) != C2L.end());
  return C2L[class_id];
}

int Mapper::negativeID() {
  return 92;
}
